import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';

class AppToolToast {
  static void showToast(String msg) {
    // JFUtilToast.setToastStyle();
    EasyLoading.showToast(msg);
    // SmartDialog.showToast(msg, alignment: Alignment.topCenter);
  }

  static void showLoading({String status = '加载中...'}) {
    EasyLoading.instance.userInteractions = false;
    EasyLoading.show(status: status);
    // SmartDialog.showLoading(msg: status, clickMaskDismiss: false);
    // EasyLoading.show(status: status, indicator: WidgetSpinkit.showSpinkit());
  }

  static void showProgress(double value, {String status = 'loading...'}) {
    // SmartDialog.showLoading(msg: status, clickMaskDismiss: false);
    EasyLoading.showProgress(value, status: status);
  }

  static void dismiss() {
    EasyLoading.instance.userInteractions = true;
    EasyLoading.dismiss();
    // SmartDialog.dismiss();
  }

  static void setToastStyle() {
    EasyLoading.instance
      ..toastPosition = EasyLoadingToastPosition.bottom
      ..loadingStyle = EasyLoadingStyle.custom
      ..backgroundColor = const Color(0xFF000000).withOpacity(0.5)
      ..indicatorColor = Colors.white
      ..progressColor = Colors.white
      ..textColor = Colors.white
      ..fontSize = 16
      ..contentPadding =
          const EdgeInsets.symmetric(horizontal: 20, vertical: 10)
      ..indicatorType = EasyLoadingIndicatorType.circle
      ..radius = 20
      ..userInteractions = true;
  }
}
